package com.code.soulqlexpress.func;

import com.ql.util.express.Operator;
import com.ql.util.express.OperatorOfNumber;

/**
 * @author yzh
 * @date 2020/1/17
 * @Content: 去除null, 相加
 */
public class SumOperator extends Operator {
    @Override
    public Object executeInner(Object[] objects) throws Exception {
        Boolean allEqNull = true;
        Object sum = 0;
        for (Object object : objects) {
            if (object != null) {
                allEqNull = false;
                sum = OperatorOfNumber.add(sum, object, this.isPrecise);
            }
        }
        if (allEqNull) {
            return null;
        }
        return sum;
    }
}
